<?php
namespace app\index\controller;

use think\Controller;
use think\Db;

class Recommend extends CommonController
{
    public function index()
    {
        return $this->fetch('recommend');
    }

    public function getNew()
    {
        // http://route.showapi.com/196-1?showapi_appid%253Dmyappid%2526num%253D10%2526page%3D1%26showapi_sign=mysecret
        $http = 'http://route.showapi.com/196-1?';
        $showapi_appid = '59404';
        $num = '10';
        $page = '2';
        $showapi_sign = '31e564784310401d8db97a88d355a2be';
        $http = $http . 'showapi_appid=' . $showapi_appid . '&num=' . $num . '&page=' . $page . '&showapi_sign=' . $showapi_sign;
        $curl =  curl_init();
        curl_setopt($curl, CURLOPT_URL, $http);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); // 从证书中检查SSL加密算法是否存在
        $tmpInfo = curl_exec($curl); //返回api的json对象
        //关闭URL请求
        curl_close($curl);
        //$tmpInfo='{"showapi_res_error":"","showapi_res_code":0,"showapi_res_body":{"newslist":[{"title":"中国女乒3将全胜！世界冠军遭横扫 小魔王连输2场","picUrl":"http:\/\/d.ifengimg.com\/w145_h103\/p0.ifengimg.com\/pmop\/2018\/0316\/789F5C94B6FF4E03D30F3478FF9AE61F2295B55A_size26_w579_h399.jpeg","description":"凤凰体育","ctime":"2018-03-16 15:00","url":"http:\/\/sports.ifeng.com\/a\/20180316\/56792916_0.shtml"},{"title":"世乒赛国乒选拔赛男队梁靖崑领跑 女队陈梦全胜","picUrl":"http:\/\/d.ifengimg.com\/w145_h103\/p0.ifengimg.com\/pmop\/2018\/0316\/93E52442CCACE767C5D23588B4F36CCEBCE1AEDF_size28_w640_h431.jpeg","description":"凤凰体育","ctime":"2018-03-16 11:32","url":"http:\/\/sports.ifeng.com\/a\/20180316\/56792963_0.shtml"},{"title":"国乒世界冠军连输4场 林高远大溃败惨遭3-0横扫","picUrl":"http:\/\/d.ifengimg.com\/w145_h103\/p0.ifengimg.com\/pmop\/2018\/0316\/3B95A4F8A685D4EF65D9B46128CC80C4CD0399E7_size32_w690_h478.jpeg","description":"凤凰体育","ctime":"2018-03-16 15:00","url":"http:\/\/sports.ifeng.com\/a\/20180316\/56792990_0.shtml"},{"title":"印第赛费德勒两盘力克郑泫 卡萨金娜送蛋横扫科贝尔","picUrl":"http:\/\/d.ifengimg.com\/w145_h103\/p0.ifengimg.com\/pmop\/2018\/0316\/627907D38E60ACB57876B9908131245BE5395C4D_size23_w612_h408.jpeg","description":"凤凰体育","ctime":"2018-03-16 15:00","url":"http:\/\/sports.ifeng.com\/a\/20180316\/56792995_0.shtml"},{"title":"短道世锦赛韩天宇徐一拉冤家路窄 安贤洙参赛","picUrl":"http:\/\/d.ifengimg.com\/w145_h103\/p0.ifengimg.com\/pmop\/2018\/0316\/06316AC47AA70D3065766DA915BE07AEE7606996_size627_w865_h533.png","description":"凤凰体育","ctime":"2018-03-16 13:26","url":"http:\/\/sports.ifeng.com\/a\/20180316\/56793021_0.shtml"},{"title":"中国女乒3将2战全败！国乒世界冠军遭横扫 国乒小魔王连输2场垫底","picUrl":"http:\/\/d.ifengimg.com\/w145_h103\/p0.ifengimg.com\/pmop\/2018\/0316\/14730432466B555C40A1D54CBBFD5E19CDDF1EE2_size27_w578_h385.jpeg","description":"凤凰体育","ctime":"2018-03-16 12:46","url":"http:\/\/sports.ifeng.com\/a\/20180316\/56792916_0.shtml"},{"title":"林丹再喷羽联：大比赛就判得松？对羽毛球没信心","picUrl":"http:\/\/d.ifengimg.com\/w145_h103\/p1.ifengimg.com\/a\/2018_11\/731d5dfe4917602_size32_w600_h400.jpg","description":"凤凰体育","ctime":"2018-03-16 12:00","url":"http:\/\/sports.ifeng.com\/a\/20180316\/56788383_0.shtml"},{"title":"王一梅被“雪藏”事出有因！退役她还没有考虑过","picUrl":"http:\/\/d.ifengimg.com\/w145_h103\/p0.ifengimg.com\/pmop\/2018\/0315\/8E88B692C184EB3BCD56F26BB76D016CF87ABA82_size51_w640_h480.jpeg","description":"凤凰体育","ctime":"2018-03-15 17:56","url":"http:\/\/sports.ifeng.com\/a\/20180316\/56788761_0.shtml"},{"title":"韩体坛曝性丑闻！俩冬奥选手性侵女队友 遭终身禁赛","picUrl":"http:\/\/d.ifengimg.com\/w145_h103\/img1.ugc.ifeng.com\/newugc\/20180316\/10\/wemedia\/1e2453c879f2c1a2f3ebaa239c190900826b910b_size168_w544_h348.png","description":"凤凰体育","ctime":"2018-03-16 10:09","url":"http:\/\/sports.ifeng.com\/a\/20180316\/56787307_0.shtml"},{"title":"女排季军战遭调侃：赶紧打完 趁早回国家队找状态","picUrl":"http:\/\/d.ifengimg.com\/w145_h103\/p0.ifengimg.com\/pmop\/2018\/0316\/F43738A99C02C5DA1BC5C122BC6C6D5CD89E4A7E_size36_w550_h309.jpeg","description":"凤凰体育","ctime":"2018-03-16 08:00","url":"http:\/\/sports.ifeng.com\/a\/20180316\/56780654_0.shtml"}],"code":200,"msg":"success"}}';
        return $tmpInfo;

    }

    
    function getKnowledge()
    {

        $res=Db::table('knowledge')->select();
        $this->assign('list',$res);
        return $this->fetch('littleKnowledge');
        # code...
    }

    function getSelectKnowledge($where){
        $res = Db::table('knowledge')->where('title','like',"%$where%")->select();
        $this->assign('list',$res);
        return $this->fetch('littleKnowledge');
    }

}
